package com.tuanzi.loan.workflow.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.tuanzi.loan.workflow.entity.Opinion;
import com.tuanzi.loan.workflow.repository.OpinionRepository;
import com.tuanzi.loan.workflow.service.OpinionService;

/**
 * @author Ray
 * @date 2018/01/24
 */
@Service
@Transactional
public class OpinionServiceImpl implements OpinionService {

	@Autowired
	private OpinionRepository opinionRepository;

	@Override
	public List<Opinion> findAllByProcInstId(String procInstId) {
		return opinionRepository.findAllByProcInstIdOrderByCreateTime(procInstId);
	}

	@Override
	public Opinion findByProcDefIdAndTaskId(String procInstId, String taskId) {
		return opinionRepository.findByProcInstIdAndTaskId(procInstId, taskId);
	}

	@Override
	public Opinion saveOrUpdate(Opinion opinion) {
		return opinionRepository.save(opinion);
	}

}
